$(document).ready(function () {
    init()

    new Vue({
        el: '#app',
        data: {
            pageInfo: {list: {length: 0}},
            spb: {},
            payMethod: '零钱'
        },
        methods: {
            payBack(spb) {
                // console.log(spb)
                spb.spbTime = spb.spbTime.substr(0, 10)
                spb.lendingTime = spb.lendingTime.substr(0, 10)
                this.spb = spb
            },
            findShouldPayBackCustomByLoanIdByPage(pageNum, pageSize) {
                axios.get('findShouldPayBackCustomByLoanIdByPage', {
                    params: {
                        pageNum: pageNum,
                        pageSize: pageSize
                    }
                }).then(
                    response => {
                        console.log(response.data)
                        this.pageInfo = response.data
                    },
                    error => {
                        console.log(error.message)
                    }
                )
            },
            payBackSuccess() {
                // console.log("success")
                // console.log(this.payMethod)
                console.log(this.spb)
                let params = new URLSearchParams();
                params.append('repaymentMethod', this.payMethod)
                params.append('isRepayment', '是')
                params.append('overdueFee', '0')
                params.append('spbId', this.spb.spbId)
                params.append('spbMoney', this.spb.spbMoney)
                // console.log('params', params)

                axios.post('insertRepayment', params).then(
                    response => {
                        console.log(typeof response.data)
                        if (response.data) {
                            this.findShouldPayBackCustomByLoanIdByPage(1, 6)
                            $('#myModal').modal('hide')
                        }
                        // this.pageInfo = response.data
                    },
                    error => {
                        console.log(error.message)
                    }
                )
            }
        },
        computed: {
            remainderDays() {
                return function (date) {
                    return Math.floor((Date.parse(date) - Date.parse(new Date()))/(1*24*60*60*1000))
                }
            }
        },
        created() {
            this.findShouldPayBackCustomByLoanIdByPage(1, 6);
        }
    })

})

function init() {
    $("#header").load("jump?url=common/header", null, function () {
        $(".nav_navs").children().eq(5).children().attr("class", "on")
        $(".header_h1").css("margin-top", "0px")
        $(".header_weixin").css("margin-top", "0px")
        $(".header_weixin>img").mouseover(function(){
            $(".header_weixinBig").css('display','block');
        })
        $(".header_weixin>img").mouseout(function(){
            $(".header_weixinBig").css('display','none');
        })
    })

    $("#footer").load("jump?url=common/footer")
}
